package com.hsy.order.login.store

import com.flux.action.RxAction
import com.flux.action.RxStoreChange
import com.flux.dispatcher.Dispatcher
import com.hsy.order.base.action.ActionType
import com.hsy.order.base.action.Key
import com.hsy.order.base.store.BaseStore
import com.hsy.order.login.data.LoginResult

/**
 * 登录数据缓存
 * Created on 2017/12/4.
 *
 * @author Yang
 */
class LoginStore(dispatcher: Dispatcher) : BaseStore(dispatcher) {

    /**
     * 登陆结果
     */
    lateinit var result: LoginResult

    override fun onRxAction(action: RxAction) {
        if (handleSuper) super.onRxAction(action)
        if (action.type == ActionType.LOGIN) {
            if (action.success) {
                //登录成功
                result = action[Key.LOGIN_RESULT]
            }
        }
        postChange(RxStoreChange(tag, action.type, action.success))
    }
}